package com.chenyanqing.sqlsession;

import com.chenyanqing.config.Configuration;
import com.chenyanqing.config.XMLConfigBuilder;
import com.chenyanqing.pojo.MapperStatement;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.dom4j.DocumentException;

import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class SqlSessionFactoryBuilder {



    public SqlSessionFactory build(InputStream inputStream) throws Exception {

        //1\使用dom4j解析inputstream 配置文件流，封装configuration对象
        com.chenyanqing.config.XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        //2\创建sqlsessionFactory对象，生产sqlsession
        return  new DefaultSqlSessionFactory(configuration);

    }



}
